# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgbase=python-xhtml2pdf
pkgname=('python2-xhtml2pdf' 'python-xhtml2pdf')
_pkgname=xhtml2pdf
pkgver=0.2.17
pkgrel=1
pkgdesc='PDF generator using HTML and CSS.'
arch=('any')
url='https://pypi.org/project/xhtml2pdf/#files'
license=('APACHE')
makedepends=('python2-setuptools' 'python-setuptools')
source=("https://files.pythonhosted.org/packages/source/${_pkgname::1}/$_pkgname/$_pkgname-$pkgver.tar.gz")
sha512sums=('584070777cdbb3b45bdb3701b5598d22b9154434c61f9d0e941d46743862ffb6750cbda28833deed0e0df8305ab3c3df2ba4793b8a18a5728f815a9a17f7a4ed')

prepare() {
  cp -a "$_pkgname-$pkgver"{,-2}
}

build() {
  cd "$_pkgname-$pkgver-2"

  python2 setup.py build

  cd "$srcdir/$_pkgname-$pkgver"

  python setup.py build
}

package_python2-xhtml2pdf() {
  depends=('python2' 'python2-html5lib' 'python2-pillow6' 'python2-six'
           'python2-pypdf2' 'python2-reportlab')

  cd "$_pkgname-$pkgver-2"

  python2 setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build

  for i in "$pkgdir/usr/bin/"* ; do
    mv $i "${i}2"
  done
}

package_python-xhtml2pdf() {
  depends=('python' 'python-html5lib' 'python-pillow' 'python-six'
           'python-pypdf2' 'python-reportlab')

  cd "$_pkgname-$pkgver"

  python setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build
}

